home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / comp / fetchvar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.7 KB  |  59 lines

  1. /*
  2.                             F E T C H V A R . C
  3.  
  4.     Frame organization:
  5.  
  6.             Low address
  7.                         Local x     <- Var 0xbffc   = 0xbfff - x
  8.                         Local ...   <- Var 0xbffd   = 0xbfff - ...
  9.                         Local 1     <- Var 0xbffe   = 0xbfff - 1
  10.                         Local 0     <- Var 0xbfff   = 0xbfff - 0
  11.                         Old BP      <- Var 0xc000
  12.                         RA          <- Var 0xc001
  13.             parameters: Par 0       <- Var 0xc002   = 0xc002 + 0
  14.                         Par 1       <- Var 0xc003   = 0xc002 + 1
  15.                         ...
  16.             High Address
  17. */
  18.  
  19. #include "iccomp.h"
  20.  
  21. ESTRUC_ fetchvar()
  22. {
  23.     register unsigned
  24.         index;
  25.     E_TYPE_
  26.         type = 0;
  27.     ESTRUC_
  28.         ret;
  29.  
  30.     ret = stackframe(0);
  31.  
  32.                                             /* not a local variable ? */
  33.     if ((index = looksym(&local)) == local.n_defined)
  34.     {                                       /* not a global variable ? */
  35.         if ((index = looksym(&global)) == global.n_defined)
  36.         {
  37.             index = 0xffff;
  38.             semantic("%s undefined", string);
  39.         }
  40.         else
  41.             type = global.symbol[index].var.type;
  42.     }
  43.     else
  44.     {
  45.         type = local.symbol[index].var.type;
  46.         if (index < n_params)               /* Parameters: */
  47.             index += 0xc002;
  48.         else                                /* Locals: */
  49.             index = 0xbfff - (index - n_params);
  50.     }
  51.  
  52.     if (index != 0xffff)
  53.     {
  54.         ret.evalue = index;                /* set index and type */
  55.         ret.type =  type;
  56.     }
  57.     return (ret);                           /* return the frame */
  58. }
  59.